package Comun;


import java.util.Timer;
import java.util.TimerTask;


public class EfectoDisolver {


  private org.edisoncor.gui.util.WindowsUtil opacidad;
  private javax.swing.JFrame frame;
  private float factor=.9f;
  Timer timer;


  public void cerrar(){
      timer = new Timer();
      opacidad.makeWindowsOpacity(getFrame(),factor);
           timer.schedule(new tick(), 0, 40);


  }

  public void abrir(){
   timer = new Timer();
   factor=0;
   opacidad.makeWindowsOpacity(getFrame(),factor);
   frame.setVisible(true);
           timer.schedule(new tick2(), 0, 40);

  }

    /**
     * @return the frame
     */
    public javax.swing.JFrame getFrame() {
        return frame;
    }

    /**
     * @param frame the frame to set
     */
    public void setFrame(javax.swing.JFrame frame) {
        this.frame = frame;
    }

    class tick extends TimerTask{
        @Override
        public void run() {
            if(factor>0){
            factor=factor-.1f;
            opacidad.makeWindowsOpacity(getFrame(),factor);
            }else{
                timer.cancel();
                getFrame().dispose();
            }
            }
        }

class tick2 extends TimerTask{
        @Override
        public void run() {
            if(factor<.9f){
            factor=factor+.1f;
            opacidad.makeWindowsOpacity(getFrame(),factor);
            }else{
                timer.cancel();
            }
            }
        }

    
}
